package test.org.huhuiyu.database;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
	public static final String DRIVER = "com.mysql.jdbc.Driver";
	public static final String URL = "jdbc:mysql://127.0.0.1:3306/hibernate_demo?characterEncoding=utf8";
	public static final String USER = "root";
	public static final String PASSWORD = "paul";

	static {
		try {
			Class.forName(DRIVER);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}

	public static java.sql.Connection getConnection() throws Exception {
		return DriverManager.getConnection(URL, USER, PASSWORD);
	}

	public static void main(String[] args) throws Exception {
		Connection conn = DBConnection.getConnection();
		System.out.println(conn.getCatalog());
		conn.close();
	}
}